package com.minhua.jijiehao2.mainframe.account.channellistactivity.impl

import com.minhua.jijiehao2.base.BaseMvpPresenter
import com.minhua.jijiehao2.bean.BaseBean
import com.minhua.jijiehao2.bean.ChannelBean
import com.minhua.jijiehao2.constants.DefineKey
import com.minhua.jijiehao2.http.CallBack
import com.minhua.jijiehao2.http.ParamsMap
import com.minhua.jijiehao2.mainframe.account.channellistactivity.imp.IChannelListPresenter
import com.minhua.jijiehao2.mainframe.account.channellistactivity.imp.IChannelListView

class ChannelListPresenter : BaseMvpPresenter<IChannelListView>(), IChannelListPresenter {

    private val mChannelListModel = ChannelListModel()

    private var currentPage = 1

    override fun getListChannel() {
        currentPage = 1
        doHttp()
    }

    override fun loadMoreListChannel() {
        currentPage++
        doHttp()
    }

    private fun doHttp() {
        val map = ParamsMap()
        map.put(DefineKey.CURRENT_PAGE, currentPage)
        map.put(DefineKey.MONEY_INDEX, 0)
        map.put(DefineKey.DATE_INDEX, 0)
        mChannelListModel.getChannelList(map, object : CallBack<List<ChannelBean>>() {
            override fun onSuccess(t: BaseBean<List<ChannelBean>>) {
                v?.onChannelListSuccess(t.data!!, currentPage == 1)
            }
        })

    }
}